/**
 * Copyright (c) 2020-2021 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 *
 */
/**
 * @file    turbox_timer.c
 * @brief   harmony bl platform timer adaptor
 * @details
 * @version 1.0 
 * @author  ThunderSoft  
 * @date    2020/12/3
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2020/12/3                ThunderSoft         Create it. 
 *
 */
#include "stdio.h"
#include "plic.h"
#include "soc.h"
#include "los_reg.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

static VOID OsMachineExternalInterrupt(UINT32 arg)
{
}

VOID PlicIrqInit()
{
    UINT32 ptr;

    puts("[IRQ] Clearing and Disable all the pending IRQ...\r\n");

    /*clear mask*/
    for (ptr = 0x02800400; ptr < 0x02800400 + 128; ptr++) {
        *(UINT8*)ptr = 0;
    }
    /*clear pending*/
    for (ptr = 0x02800000; ptr < 0x02800000 + 128; ptr++) {
        *(UINT8*)ptr = 0;
    }
}

VOID PlicIrqSetPrio(UINT32 vector, UINT32 pri)
{
}

VOID PlicIrqPendingSet(UINT32 vector)
{
    *(volatile UINT8*)(CLIC_HART0_ADDR + CLIC_INTIP + vector) = 1;
}

VOID PlicIrqPendingClear(UINT32 vector)
{
    *(volatile UINT8*)(CLIC_HART0_ADDR + CLIC_INTIP + vector) = 0;
}

VOID PlicIrqEnable(UINT32 vector)
{
    *(volatile UINT8*)(CLIC_HART0_ADDR + CLIC_INTIE + vector) = 1;
}

VOID PlicIrqDisable(UINT32 vector)
{
    *(volatile UINT8*)(CLIC_HART0_ADDR + CLIC_INTIE + vector) = 0;
}

#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

